class EventDurationToExpireDate < ActiveRecord::Migration
  def self.up
    add_column :events, :expire_date, :datetime, :null => false
    Event.find(:all).each { |event| event.expire_date = event.due_date + event.duration.tv_secs }
    remove_column :events, :duration
  end

  def self.down
    add_column :events, :duration, :time, :null => false
    Event.find(:all).each { |event| event.duration = (event.expire_date - event.due_date).to_i }
    remove_column :events, :expire_date
  end
end
